package com.example.smartcity_40.Outpatient.apter;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.smartcity_40.Outpatient.ModifyVisitorActivity;
import com.example.smartcity_40.Outpatient.bean.DepartmentBean;
import com.example.smartcity_40.Outpatient.bean.OutpatienttypeBean;
import com.example.smartcity_40.Outpatient.bean.RegularregistrationBean;
import com.example.smartcity_40.R;

import java.util.List;

public class RegularregistrationApter extends  RecyclerView.Adapter<RegularregistrationApter.Myhot> {

    private Context context;
    private List<DepartmentBean.RowsBean> list;

    public RegularregistrationApter(Context context) {
        this.context = context;
    }

    public void setDate(List<DepartmentBean.RowsBean> list){
        this.list = list;
    }
    @NonNull
    @Override
    public RegularregistrationApter.Myhot onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View inflate = LayoutInflater.from(context).inflate(R.layout.l_item_regularregistration, null);
        return new RegularregistrationApter.Myhot(inflate);
    }

    @Override
    public void onBindViewHolder(@NonNull RegularregistrationApter.Myhot holder, int position) {
        try {


            String serviceName = list.get(position).getPatientName();
            if(!TextUtils.isEmpty(serviceName)){
                holder.patientName.setText("预约人: "+serviceName);
            }

            String type = list.get(position).getType();
            if("1".equals(type)){
                type = "普通号";
            }else  if("2".equals(type)){
                type = "专家号";
            }
            if(!TextUtils.isEmpty(type)){
                holder.type.setText("类型: "+type);
            }
            String reserveTime = list.get(position).getReserveTime();
            if(!TextUtils.isEmpty(reserveTime)){
                holder.createTime.setText("时间: "+reserveTime);
            }

           /* holder.relayout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent integer = new Intent(context, ModifyVisitorActivity.class);
                    integer.putExtra("hospitalid",String.valueOf(list.get(position).getId()));
                    context.startActivity(integer);
                }
            });*/
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public int getItemCount() {
        return list==null?0:list.size();
    }

    class Myhot extends RecyclerView.ViewHolder{

        private final TextView patientName;
        private final TextView type;
        private final TextView createTime;
        private final RelativeLayout relayout;

        public Myhot(@NonNull View itemView) {
            super(itemView);
            type = itemView.findViewById(R.id.type);
            patientName = itemView.findViewById(R.id.patientName);
            createTime = itemView.findViewById(R.id.createTime);
            relayout = itemView.findViewById(R.id.relayout);
        }
    }
}




